home *** CD-ROM | disk | FTP | other *** search
/ Total Network Tools 2002 / NextStepPublishing-TotalNetworkTools2002-Win95.iso / Archive / Misc Servers / Zope.exe / DTML-SQLGROUP.STX < prev    next >
Encoding:
Text File  |  2000-10-12  |  2.3 KB  |  99 lines

  1. sqlgroup: Formats complex SQL expressions
  2.  
  3.     The 'sqlgroup' tag formats complex boolean SQL expressions. You
  4.     can use it along with the 'sqltest' tag to build dynamic SQL
  5.     queries that tailor themselves to the environment. This tag is
  6.     used in SQL Methods.
  7.  
  8.   Syntax
  9.  
  10.     'sqlgroup' tag syntax::
  11.  
  12.       <dtml-sqlgroup>
  13.       [<dtml-or>]
  14.       [<dtml-and>]
  15.       ...
  16.       </dtml-sqlgroup>
  17.  
  18.     The 'sqlgroup' tag is a block tag. It is divided into blocks with
  19.     one or more optional 'or' and 'and' tags. 'sqlgroup' tags can be
  20.     nested to produce complex logic.
  21.  
  22.   Attributes
  23.  
  24.     required=boolean -- Indicates whether the group is required. If it
  25.     is not required and contains nothing, it is excluded from the DTML
  26.     output.
  27.  
  28.     where=boolean -- If true, includes the string "where". This is
  29.     useful for the outermost 'sqlgroup' tag in a SQL 'select' query.
  30.  
  31.   Examples
  32.  
  33.     Sample usage
  34.  
  35.       select * from employees 
  36.       <dtml-sqlgroup where>
  37.         <dtml-sqltest salary op=gt type=float optional>
  38.       <dtml-and>
  39.         <dtml-sqltest first op=eq type=string multiple optional>
  40.       <dtml-and>
  41.         <dtml-sqltest last  op=eq type=string multiple optional>
  42.       </dtml-sqlgroup>  
  43.  
  44.     If 'first' is 'Bob' and 'last' is 'Smith, McDonald' it renders::
  45.  
  46.       select * from employees
  47.       where
  48.       (first='Bob'
  49.        and
  50.        last in ('Smith', 'McDonald')
  51.       )
  52.  
  53.     If 'salary' is 50000 and 'last' is 'Smith' it renders::
  54.  
  55.       select * from employees
  56.       where 
  57.       (salary > 50000.0
  58.        and
  59.        last='Smith'
  60.       )
  61.  
  62.     Nested 'sqlgroup' tags::
  63.  
  64.       select * from employees
  65.       <dtml-sqlgroup where>
  66.         <dtml-sqlgroup>
  67.            <dtml-sqltest first op=like type=string>
  68.         <dtml-and>
  69.            <dtml-sqltest last op=like type=string>
  70.         <dtml-sqlgroup>
  71.       <dtml-or>
  72.         <dtml-sqltest salary op=gt type=float>
  73.       </dtml-sqlgroup>
  74.  
  75.     Given sample arguments, this template renders to SQL like so::
  76.  
  77.       select * form employees
  78.       where
  79.       (
  80.         (
  81.          name like 'A*'
  82.          and
  83.          last like 'Smith'
  84.          )
  85.        or
  86.        salary > 20000.0
  87.       )
  88.  
  89.   See Also
  90.  
  91.     "sqltest tag":dtml-sqltest.stx
  92.  
  93.  
  94.  
  95.  
  96.  
  97.  
  98.  
  99.